/*
 * @Author: your name
 * @Date: 2021-07-07 15:01:29
 * @LastEditTime: 2022-08-03 17:57:56
 * @LastEditors: 11 11
 * @Description: In User Settings Edit
 * @FilePath: \exc-tl1-2\SRC\user_src\at_cmd_tx.h
 */
/**
	*文件名称：
	*
	*文件日期：
	*
	*文件描述：
	*
	*文件版本：V1.0
	*
	*/

#ifndef AT_CMD_TX_H
#define AT_CMD_TX_H

/* 头文件包含区	*/
#include "stdint.h"
#include "uart.h"

/* 类型声明区 */
#define SET 1
#define RESET 0
#define SEND_BUF_SIZE 512
#if (SEND_BUF_SIZE != 512)

#error "因app区中断使用的是boot区的终端服务函数，所以SEND_BUF_SIZE大小必须为512和出厂时boot区变量地址一致，否则会造成地址偏移导致boot区中断服务函数找不到这个变量"
#endif
/* 宏定义区 */

//#define OLD_BOARD
#ifndef OLD_BOARD
//#ifdef LED_STRUCTURE
#if (LED_STRUCTURE == NORMAL_STRUCTURE)

#define POWER_KEY(x) x ? (GPIO->PBSET |= 1 << 13) : (GPIO->PBCLR |= 1 << 13)
#define POWER_ON(x) x ? (GPIO->PBSET |= 1 << 12) : (GPIO->PBCLR |= 1 << 12)
//#define POWER_KEY(x) x ? (GPIO->PCSET |= 1 << 5) : (GPIO->PCCLR |= 1 << 5)
//#define POWER_ON(x) x ? (GPIO->PCSET |= 1 << 4) : (GPIO->PCCLR |= 1 << 4)


#define WIRELESS_RESET(x) x ? (GPIO->PASET |= 1 << 26) : (GPIO->PACLR |= 1 << 26)
#else

#define POWER_KEY(x) x ? (GPIO->PCSET |= 1 << 5) : (GPIO->PCCLR |= 1 << 5)
#define POWER_ON(x) x ? (GPIO->PBSET |= 1 << 12) : (GPIO->PBCLR |= 1 << 12)

#define WIRELESS_RESET(x) x ? (GPIO->PASET |= 1 << 26) : (GPIO->PACLR |= 1 << 26)
#endif


#else
#define POWER_KEY(x) x ? (GPIO->PCSET |= 1 << 4) : (GPIO->PCCLR |= 1 << 4)
#define POWER_ON(x) x ? (GPIO->PCSET |= 1 << 2) : (GPIO->PCCLR |= 1 << 2)
#endif

typedef enum
{
	SIM_UNKOWN,
	SIM_CMCC, //謯箂NE镀
	SIM_CTCC, //謯箂礶娕
	SIM_CUCC, //謯箂IRK?
} sim_type_t;

/*这段内存一定不可以改变，如果需要增加变量，就增加在最后面*/
#pragma pack(1)
typedef struct
{
	uint8_t my_at_sendbuf[SEND_BUF_SIZE / 2];
	uint8_t my_at_data_str[SEND_BUF_SIZE];
	uint16_t my_at_sendlen;
} main_tx_struct;
extern main_tx_struct main_tx;
#pragma pack()

/* 函数声明区 */
void AT_TX_Restart(void);
void AT_TX_ATI(void);
void AT_TX_ATE0(void);
void AT_TX_CPIN(void);
void AT_TX_QCCID(void);
void AT_TX_IMEI(void);
void AT_TX_CREG(void);
void AT_TX_QSCLK(void);
void AT_TX_CGATT_GET(void);
void AT_TX_CCLK(void);
void AT_TX_UPLINK03(void);
void AT_TX_UPLINK06(void);
void AT_TX_UPLINK10(void);
void AT_TX_QMTCFG_0(void);
void AT_TX_QMTCFG_1(void);
void AT_TX_QMTCFG_2(void);
void AT_TX_QMTCFG_3(void);
void AT_TX_QMTOPEN(void);
void AT_TX_QMTCONN(void);
void AT_TX_QMTSUB(void);
void AT_TX_CSQ(void);
void AT_TX_CLCK(void);
void AT_TX_QMTPUB_UP_LAMP(void);
void send_waiting_to_receive(void);
void recv_waiting_to_receive(void);
void my_usart_send_ERROR(uint8_t *pData);
void AT_TX_QMTPUB_1007(void);
void AT_TX_QMTPUB_2018(void);
void myitoa(uint8_t *str_in, uint16_t len, uint8_t *str_out);
void my_usart_send_data(uint8_t *pData, uint16_t Len);

void restore_factory_cclk_way(void);
#if (PROJECT_TYPEDEF == NB_ONENET ||PROJECT_TYPEDEF == NB)
void AT_TX_CFUN0(void);
void AT_TX_CFUN1(void);
void AT_TX_NCSEARFCN(void);
void AT_TX_MIPLCONFIG(void);
void AT_TX_OPENLED(void);
#endif
#if (PROJECT_TYPEDEF == NB)
void AEP_PackSend(void);
void APP_PACKsend_inquiry_vereion_19(void);
void APP_PACKsend_vereion_notify_20(void);
void APP_PACKsend_request_ota_pack_21(void);
void APP_PACKsend_report_ota_status_22(void);
void APP_PACKsend_start_ota_23(void);
void APP_PACKsend_report_ota_result_24(void);
#endif
#if (PROJECT_TYPEDEF == NB || PROJECT_TYPEDEF == NB_ONENET)
void AT_TX_SWITCH_BAUD(void);
void AT_TX_NMSTATUS(void);
void AT_TX_QCFG(void);
void AT_TX_NCDP(void);
void AT_TX_CGDCONT(void);
void AT_TX_CPSMS(void);
void AT_TX_QREGSWT(void);
void AT_TX_CEDRXS(void);
#endif

#if (PROJECT_TYPEDEF == CAT1)
void get_cclk_another_way(void);
uint16_t send_data_len(uint8_t comm_typedef);
void my_usart_send_data2(uint8_t *pData, uint16_t Len);
void my_usart_send_data1(uint8_t *pData, uint16_t Len);
#endif
#endif
